package com.lz.virtualthread.project.api.controller;

import com.lz.virtualthread.common.domain.ResponseVo;
import com.lz.virtualthread.project.api.service.ApiService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


/**
 * 虚拟现场 webflux测试
 *
 * @author xpp
 */
@RestController
@RequestMapping("/api")
public class ApiController {

    @Resource
    ApiService apiService;

    @GetMapping("/thread")
    public ResponseVo checkThread() throws InterruptedException {
        Thread.sleep(1000);
        System.out.println("虚拟线程：" + Thread.currentThread().isVirtual());
        System.out.println("线程ID：" + Thread.currentThread().threadId());
        return ResponseVo.success();
    }
    @GetMapping("/virtualThread")
    public ResponseVo virtualThread() throws InterruptedException {
        Thread.sleep(3000);
        System.out.println("虚拟线程：" + Thread.currentThread().isVirtual());
        System.out.println("线程ID：" + Thread.currentThread().threadId());
        return ResponseVo.success();
    }


}
